package JDBC;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;

public class JDBCDemo8 {
    public static void main(String[] args) throws SQLException {
        Connection conn = DBUtil.getConnection();
        String sql = "SELECT username,password "+
                     "FROM userinfo "+
                     "WHERE username=? AND password=?";
        PreparedStatement ps = conn.prepareStatement(sql);
        ps.setString(1,"谢小虫");
        ps.setString(2,"123456");
        ResultSet rs = ps.executeQuery();
        while (rs.next()){
            String username = rs.getString("username");
            String password = rs.getString("password");
            System.out.println(username+" , "+password);
        }
    }
}
